package com.nimitz.task.service.impl;

import com.nimitz.common.core.domain.entity.SysUser;
import com.nimitz.task.domain.Task;
import com.nimitz.task.domain.TaskResult;
import com.nimitz.task.mapper.TaskMapper;
import com.nimitz.task.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskMapper taskMapper;

    @Override
    public List<Task> selectAll(Long auditorId, String state) {
        List<Task> list = taskMapper.selectAll(auditorId,state);
        return list;
    }

    @Override
    public void updateTask(Task task) {
        taskMapper.updateTask(task);
    }

    @Override
    public void addTask(Task task) {
        taskMapper.addTask(task);
    }

    @Override
    public TaskResult selectById(Long id) {
        TaskResult taskResult = taskMapper.selectById(id);
        return taskResult;
    }

    @Override
    public void deleteById(Long id) {
        taskMapper.deleteById(id);
    }

    @Override
    public int countAll() {
        int countAll = taskMapper.countAll();
        return countAll;
    }

    @Override
    public int countCompleted() {
        int countCompleted = taskMapper.countCompleted();
        return countCompleted;
    }

    @Override
    public void updateAuditor(Task task) {
        taskMapper.updateAuditor(task);
    }

    @Override
    public List<SysUser> selectByRoleId() {
        List<SysUser> list = taskMapper.selectByRoleId();
        return list;
    }
}
